package main

import (
	"fmt"
)

type Student struct {
	name    string
	age     int
	sex     int
	score   float64
	address string
}

func main0701() {
	//定义结构体遍历
	stu := Student{
		name:    "HH",
		age:     0,
		sex:     0,
		score:   0,
		address: "CD",
	}
	fmt.Printf("%p\n", &stu)
}

func main() {
	m := make(map[int]Student)
	s1 := Student{
		name:    "H1",
		age:     0,
		sex:     0,
		score:   0,
		address: "CD",
	}
	m[1001] = s1

	//不允许单独对map的value为结构体的字段写入，涉及到map底层的内存分布问题
	//m[1001].name="H2"
	//如果要修改
	sv, ok := m[1001]
	if ok {
		sv.name = "h2"
		//修改完成后重新写入
		m[1001] = sv
	}
	fmt.Println(m)
	fmt.Println(m[1001].name)
}
